package org.shop.search.controller;

import org.shop.common.pojo.Result;
import org.shop.common.pojo.StatusCode;
import org.shop.search.service.SkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping(value = "/search")
public class SkuController {
    @Autowired
    private SkuService skuService;

    @GetMapping(value = "import")
    public Result importSkuData(){
        skuService.importSkuData();
        return new Result(true, StatusCode.OK,"导入sku数据到索引数据库成功！");
    }
    /**
     * 搜索
     */
    @GetMapping
    public Map<String,Object> search(@RequestParam(required = false) Map<String, String> searchMap) throws Exception {
        return skuService.search(searchMap);
    }
}
